import logging

from appium import webdriver
from time import sleep
import sys
sys.path.append('..')

# 引入工具
from common.a_tool.get_yaml_data import get_yaml_data

path = r'..\config\desired_caps.yml'
def desired_caps():
    data = get_yaml_data(path)
    desired_caps = {}
    desired_caps['platformName'] = data['platformName']
    desired_caps['platformVersion'] = data['platformVersion']
    desired_caps['deviceName'] = data['deviceName']
    desired_caps['app'] = data['app']
    desired_caps['appPackage'] = data['appPackage']
    desired_caps['appActivity'] = data['appActivity']
    desired_caps['noReset'] = data['noReset']

    driver = webdriver.Remote(f'http://{data["ip"]}:{data["port"]}/wd/hub',desired_caps)
    driver.implicitly_wait(10)
    sleep(3)
    logging.info('app start...')

    return driver
if __name__ == '__main__':
    driver = desired_caps()